/**
 * 
 * The MIT License
 * 
 * Copyright (c) 2008 the original author or authors.
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:

 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.

 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.googlecode.gchartjava;

import static com.googlecode.gchartjava.Color.*;
import static org.junit.Assert.assertEquals;

import org.junit.Test;

import com.googlecode.gchartjava.ShapeMarker.ShapeEnum;

/**
 * 
 * @author Julien Chastang (julien.c.chastang at gmail dot com)
 */
public class RadarChartExample {

	/**
	 * Testing radar charts
	 */
	@Test
	public void example1() {
		
		int count = 202;
		float[] x = new float[count];
		float[] x1 = new float[count];
		
		int cnt = 0;
		for (float i = 0; i < count; i = i + 1) {
			x[cnt] = (float)Math.sin(i/4);
			x1[cnt] = 20;
			cnt++;
		}
		
		final RadarPlot plot1 = new RadarPlot(DataUtil.normalize(x),new Color("3D5593"));
		plot1.setFillAreaColor(new Color("8FA3D6"));
		final RadarPlot plot2 = new RadarPlot(new Data(x1));
		plot2.setFillAreaColor(new Color("3D5593"));
		for (int i = 0; i < count; i = i + 20) {
			plot2.addShapeMarker(new ShapeMarker(ShapeEnum.CIRCLE,PINK,i,i,20));
		}
		final RadarChart chart = new RadarChart(plot1,plot2);
		chart.setBackgroundFill(new SolidFill(new Color("504227")));
		chart.setSpline(true);
		chart.setDataEncoding(DataEncoding.SIMPLE);
		chart.setSize(500, 500);
		chart.setTitle("Radar Chart", WHITE, 16);
		System.out.println(chart.createURLString());
		String expectedString = "http://chart.apis.google.com/chart?cht=rs&chs=500x500&chts=FFFFFF,16&chd=s:fmtz479962xqjbUNHDBABEJPWdlsz479973yrkcVOIEBABEIOVckry379973ysldWPJEBABDINUbjqx269974ztmeXQKFBABDHMTaipw2689850unfYRKFCAACGMSZhpv1589851vogZRLGCAACGLRYgou0589861vphaSMGDAACFKQXfnu0489862wqibTNHDBABFJPWe,MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM&chco=3D5593,000000&chf=bg,s,504227&chm=o,FFC0CB,1,0,20,0|o,FFC0CB,1,20,20,0|o,FFC0CB,1,40,20,0|o,FFC0CB,1,60,20,0|o,FFC0CB,1,80,20,0|o,FFC0CB,1,100,20,0|o,FFC0CB,1,120,20,0|o,FFC0CB,1,140,20,0|o,FFC0CB,1,160,20,0|o,FFC0CB,1,180,20,0|o,FFC0CB,1,200,20,0|B,8FA3D6,0,0,0|B,3D5593,1,0,0&chtt=Radar+Chart";
		assertEquals("Junit error", expectedString,chart.createURLString());
	}
}